<template>
  <div class="home">
    <el-container>
      <el-header>
        <el-row type="flex" class="row-bg">
          <el-col :span="20"
            ><div class="grid-content bg-purple">
              <h1>电商后台管理系统</h1>
            </div></el-col
          >
          <el-col :span="3"
            ><div
              class="grid-content bg-purple-light"
              style="text-align: right"
            >
              {{ getUsername }} , 欢迎您！
            </div></el-col
          >
          <el-col :span="2"
            ><div class="grid-content bg-purple" style="text-align: right">
              <el-button type="info" @click="logout">退出</el-button>
            </div></el-col
          >
        </el-row>
      </el-header>
      <el-container>
        <div class="aside">
          <!-- <div class="logo"></div> -->
          <!-- <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
            <el-radio-button :label="false">展开</el-radio-button>
            <el-radio-button :label="true">收起</el-radio-button>
          </el-radio-group> -->
          <aside-menu></aside-menu>
          <!-- :toggleView = "changeView -->
        </div>

        <!-- 路由出口 -->
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import AsideMenu from "../../components/AsideMenu.vue";
import { mapGetters } from "vuex";
export default {
  data() {
    return {};
  },
  components: {
    AsideMenu,
  },
  computed: {
    ...mapGetters(["getUsername"]),
  },
  methods: {
    // 方式一
    logout() {
      this.$confirm("是否退出登录？", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message.success("成功退出登录");
          this.$store.commit("clearToken");
          this.$router.replace({ path: "/login" });
        })
        .catch(() => {
          this.$message.info("取消退出登录");
        });
    },
    // 方式二
    // async logout(){
    //     let res = await this.$confirm('是否退出登录？', {
    //       confirmButtonText: '确定',
    //       cancelButtonText: '取消',
    //       type: 'warning'
    //     }).catch(()=> {})

    //     if(res != confirm) return this.$message.info("取消退出登录")
    //     this.$message.success("成功退出登录")
    //     this.$store.commit("clearToken")
    //     this.$router.replace({path:"/login"})

    // }
  },
};
</script>

<style lang="less" >
.home {
  height: 100%;

  .el-container {
    height: 100%;
  }
  .el-main {
    flex: 1 1 auto;
    overflow: auto;
    margin-bottom: 100px;
    .el-breadcrumb {
      background-color: initial;
      font-size: 12px;
      line-height: initial;
      height: initial;
      padding: 0px;
    }
    .el-card__body {
      min-width: 400px;
    }

    .el-table {
      margin-top: 20px;
    }
    .el-pagination {
      margin-top: 20px;
    }
  }
  .aside {
    background-color: #333744;
  }

  .el-header {
    background-color: #373d41;
    color: #fff;
    height: 60px;
    line-height: 60px;
    .el-row {
      height: 60px;
    }
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
}
</style>